#include <iostream>
#include <cstring>
using namespace std;

int main(){
	void dfs(bool (&light)[101][101], int (&number)[101][101], int i, int j, int n, int m, int &count, int flag);
	int n,m;
	cin >> n >> m;
	bool light[101][101];
	int number[101][101];
	//if no point is true , return 0
	int flag = 0;
	memset(number, 0, sizeof(number));
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++){
			char temp;
			cin >> temp;
			if(temp == '-') light[i][j] = false;
			else {
				light[i][j] = true;
				flag = 1;
			}
		}
	if(flag == 0){
		cout << 0 << endl;
		return 0;
	}

	int count = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++){
			if(light[i][j] == true && number[i][j] == 0){
				dfs(light, number, i, j, n, m, count ,0);
			}
		}
	cout << count << endl;
}

void dfs(bool (&light)[101][101], int (&number)[101][101], int i, int j, int n, int m, int &count, int flag){
	if(flag == 0) count++;
	number[i][j] = count;
	if(i - 1 >= 1 && j - 1 >= 1)
		if(light[i-1][j-1] == true && number [i-1][j-1] == 0) dfs(light, number, i-1, j-1, n, m, count, 1);
	if(i - 1 >= 1 && j + 1 <= m)
		if(light[i-1][j+1] == true && number [i-1][j+1] == 0) dfs(light, number, i-1, j+1, n, m, count, 1);
	if(i + 1 <= n && j - 1 >= 1)
		if(light[i+1][j-1] == true && number [i+1][j-1] == 0) dfs(light, number, i+1, j-1, n, m, count, 1);
	if(i + 1 <= n && j + 1 <= m)
		if(light[i+1][j+1] == true && number [i+1][j+1] == 0) dfs(light, number, i+1, j+1, n, m, count, 1);
	if(i - 1 >= 1)
		if(light[i-1][j] == true && number[i-1][j] == 0) dfs(light, number, i-1, j, n, m, count, 1);
	if(j + 1 <= m)
		if(light[i][j+1] == true && number[i][j+1] == 0) dfs(light, number, i, j+1, n, m, count, 1);
	if(i + 1 <= n)
		if(light[i+1][j] == true && number[i+1][j] == 0) dfs(light, number, i+1, j, n, m, count, 1);
	if(j - 1 >= 1)
		if(light[i][j-1] == true && number[i][j-1] == 0) dfs(light, number, i, j-1, n, m, count, 1);
	if(i - 2 >= 1)
		if(light[i-2][j] == true && number[i-2][j] == 0) dfs(light, number, i-2, j, n, m, count, 1);
	if(j + 2 <= m)
		if(light[i][j+2] == true && number[i][j+2] == 0) dfs(light, number, i, j+2, n, m, count, 1);
	if(i + 2 <= n)
		if(light[i+2][j] == true && number[i+2][j] == 0) dfs(light, number, i+2, j, n, m, count, 1);
	if(j - 2 >= 1)
		if(light[i][j-2] == true && number[i][j-2] == 0) dfs(light, number, i, j-2, n, m, count, 1);
}
